/*
 * @Author: zhangfeng
 * @Date: 2023-12-13 18:16:08
 * @LastEditTime: 2023-12-20 17:37:18
 * @LastEditors: zhangfeng
 * @Description:
 * @FilePath: \nodeapi\src\router\menu.router.js
 * © 2023 张峰，All rights reserved.
 */
const KoaRouter = require("koa-router");
const { auth } = require("../middleware/auth.middleware");
const { isHasChild } = require("../middleware/menus.middleware");
const {
  create,
  getMenus,
  update,
  deleteMenus,
} = require("../controller/menus.controller");

const router = new KoaRouter({
  prefix: "/menus",
});

// 创建菜单
router.post("/", auth, create);

// 获取菜单
router.get("/", auth, getMenus);

// 编辑菜单
router.put("/", auth, update);

// 删除菜单
router.delete("/", auth, isHasChild, deleteMenus);

module.exports = router;
